<template>
    <div>
        <Dialog @ok="ok" v-bind="$attrs" ref="dialogRef">
            <Form v-bind="$attrs" ref="formRef"></Form>
        </Dialog>
    </div>
</template>

<script lang="ts">
export default {
    name: 'DF'
}
</script>
<script lang="ts" setup>
import { ref } from 'vue';

/**
 * dialog引用
 */
const dialogRef = ref();
/**
 * form引用
 */
const formRef = ref();

const emit = defineEmits(['ok']);

/**
 * OK事件
 */
const ok = async () => {
    try {
        const model = await formRef.value.valid();
        dialogRef.value.start();
        emit('ok', model);
    } catch (error) {
        console.log(error);
    }
}

defineExpose({
    show: () => dialogRef.value.show(),
    hide: () => dialogRef.value.hide(),
    start: () => dialogRef.value.start(),
    stop: () => dialogRef.value.stop()
});
</script>

<style></style>